<?php
header("Access-Control-Allow-origin:*");
$type = $_POST["type"];
$page = $_POST["page"] ? $_POST["page"] : 1;
$pagesize = $_POST["pagesize"] ? $_POST["pagesize"] : 20;
$arr = [];
$resArr = [];
$start = ($page - 1) * $pagesize + 1;
$end = $page * $pagesize;

if ($page == 5) {
    $end = $page * $pagesize - 5;
}

if ($type == "0" || !$type) {
    for ($i = $start; $i <= $end; $i++) {
        $arr["bizs"][] = array(
            "id" => $i,
            "name" => "装修/设计" . $i,
            "addr" => "地址" . $i,
            "logo"=>"https://wnworld.com/uploads/jjd/01.jpg",
            'discount' => '满20000减500'
        );

    }
} else if ($type == "1") {
    $arr["bizs"]=[];
    // for ($i = $start; $i <= $end; $i++) {
    //        $arr["bizs"][]= array(
    //         "id" => $i,
    //         "name" => "建材/软装" . $i,
    //         "logo"=>"https://wnworld.com/uploads/jjd/01.jpg",
    //         "promotion" => "满20000减500"
    //     );
    // }

} 

$resArr["page"] = $page;
$resArr["status"] = 1;
$resArr["data"] = $arr;

// $rand = mt_rand(0, 1);

// if ($rand) {

// } else {
//     $resArr["ok"] = 0;
//     $resArr["error"] = array(
//         'code' => $ph->getErrorCode(),
//         'message' => $ph->getErrorMessage(),
//     );
// }
echo json_encode($resArr);

?>